package cn.stylefeng.guns.core.enums;

/**
 * 订单付款方式枚举
 */
public enum PaymentTypeEnum {
    SPOT(1, "现付"),
    DELIVERY(2, "到付"),
    BACK_PAY(3, "欠付"),
    SLOT(4, "月结");

    PaymentTypeEnum(int type, String desc) {
        this.type = type;
        this.desc = desc;
    }

    public int type;

    public String desc;

    public static boolean valid(Integer type) {
        if (type == null) {
            return false;
        }
        PaymentTypeEnum[] pts = PaymentTypeEnum.values();
        for (PaymentTypeEnum pt : pts) {
            if (type == pt.type) {
                return true;
            }
        }
        return false;
    }

    public static String getValue(Integer type) {
        if (type == null) {
            return "";
        }
        PaymentTypeEnum[] pts = PaymentTypeEnum.values();
        for (PaymentTypeEnum pt : pts) {
            if (type == pt.type) {
                return pt.desc;
            }
        }
        return "";
    }
}
